home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Portfolio 4.0.1
/
Scripting Extras
/
Find Duplicates.txt
< prev
next >
Wrap
Text File
|
1998-09-15
|
2KB
|
50 lines
-- Check to make sure Portfolio is running
tell application "Finder"
set P_app to every process whose name contains "Portfolio"
if P_app is {} then
display dialog ¬
"Portfolio must be running for this script to operate." buttons {"OK"} default button {"OK"}
return
end if
end tell
tell application "Portfolio"
activate
--Check to make sure the field "Duplicate" exists
set lFields to the name of every field of the first record of the front gallery
if lFields does not contain "Duplicate" then
display dialog "This script requires the catalog to have a custom integer field titled 'Duplicate'."
return
end if
-- Find All
set theQuery to "Filename" & tab & "exists"
find record of front gallery matching theQuery in all records
sort front gallery by "Filename"
-- Reset the Duplicate field
set field "Duplicate" of every record of front gallery to "0"
set theCount to count every record of front gallery
set oldFName to ""
-- Loop through all the records, checking to see if two consecutive records have
-- the same file name. If they do, mark both as duplicates
repeat with i from 1 to theCount
set newFName to filename of record i of front gallery
if newFName = oldFName then
set field "Duplicate" of records (i - 1) through i of front gallery to "1"
end if
set oldFName to newFName
end repeat
-- Find Records marked duplicate
set theQuery to "Duplicate" & tab & "equals" & tab & "1"
find record of front gallery matching theQuery in all records
sort front gallery by "Filename"
end tell